<?php
if (!defined('FosfoaSystem'))
{
    exit(1);
}
class customers_basketModel extends spModel
{
    var $pk = "customers_basket_id"; // 每个唯一的标志，可以称为主键
    var $table = "customers_basket"; // 数据表的名称

    function basketExist($customers_id,$products_id, $attributes)
    {
        $basketExist = $this->find(array('customers_id'=>$customers_id,'products_id' => $products_id,'attributes'=>$attributes));
        if ($basketExist == null)
        {
            return false;
        }
        if ($basketExist['products_id'] == $products_id)
        {
            return $basketExist;
        }
        return true;
    }
    /**
     * 删除购物车内容
     */
    function delCart($customers_id,$customers_basket_id)
    {
         $conditions = array('customers_id' => $customers_id, 'customers_basket_id' => $customers_basket_id);
         return $this->delete($conditions);
    }
    /**
     * 修改购物车
     */
    function updateCart($customers_id,$customers_basket_id,$data)
    {
         $conditions = array('customers_id' => $customers_id, 'customers_basket_id' => $customers_basket_id);
         return $this->update($conditions, $data);
    }


}